<?php

namespace console\migrations;

use console\migrations\Base;

/**
 * Handles the creation of table `{{%file}}`.
 */
class M200810032726CreateFileTable extends Base
{

    protected string $tableName = '{{%file}}';
    protected string $tableComment = '文件';

    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable($this->tableName, [
            'id' => $this->primaryKey(),
            'title' => $this->string(255)->notNull()->defaultValue('')->comment('文件名'),
            'path' => $this->string(255)->notNull()->defaultValue('')->unique()->comment('文件相对路径名'),
            'detail' => $this->text(),
            'created_at' => $this->dateTime(),
            'updated_at' => $this->dateTime(),
        ], $this->tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%file}}');
    }
}
